let tab1 = 0;//待审核 列表
let tab2 = 0;//审核通过 列表
let tab3 = 0;//审核不通过 列表
var table1;
var table2;
var table3;

layui.use('element', function () {
    const element = layui.element;
});

$(function () {
    tab1 = 1;
    layui.use('form', function () {
        const form = layui.form;
    });
    change1();
});


//切换到 待审核 列表
function change1() {
    tab1 = 1;//待审核 列表
    tab2 = 0;//审核通过 列表
    tab3 = 0;//审核不通过 列表
    $("#friendNumberButton").hide();

    //初始化 待审核 列表
    layui.use('table', function () {
        const table = layui.table;
        table1 = table.render({
            elem: '#auditTable'
            , url: ctx + "/publicUser/queryAudit",
            toolbar: '#func-export-toolbar',
            request: {
                pageName: 'currentPage',
                limitName: 'pageSize'
            },
            contentType: 'application/json',
            where: {
                condition: {
                    'name': $('#name').val(),
                    'phone': $('#phone').val()
                }
            },
            method: 'post',
            title: '所有用户列表',
            page: true,
            limit: 10,
            limits: [10, 15, 20, 25, 30],
            cols: [[

                {type: 'checkbox'},
                {
                    title: '序号', width: 50, templet: function (obj) {
                        return obj.LAY_INDEX
                    }
                },
                {title: '操作', toolbar: '#barDemo1', width: '200', align: 'center'},
                {field: 'openId', align: 'center', title: '微信openId', width: '270'},
                {field: 'name', align: 'center', title: '姓名', width: '100'},
                {
                    field: 'imgUrl',
                    align: 'center',
                    title: '照片',
                    width: '170',
                    templet: '<div><img src="{{d.imgUrl}}"></div>'
                },
                {field: 'phone', align: 'center', title: '手机号', width: '120'},
                {field: 'idCard', align: 'center', title: '身份证号', width: '180'},
                {
                    field: 'sex', align: 'center', title: '性别', width: '80',
                    templet: function (d) {
                        if (d.sex == 1) {
                            return '男';
                        } else if (d.sex == 2) {
                            return '女';
                        } else {
                            return '未知';
                        }
                    }
                },
                {field: 'age', align: 'center', title: '年龄', width: '80'},
                {field: 'communityName', align: 'center', title: '小区', width: '180'},
                {field: 'ldh', align: 'center', title: '楼栋号', width: '80'},
                {field: 'mph', align: 'center', title: '门牌号', width: '80'},
                {
                    field: 'checkState', align: 'center', title: '审核状态', width: '110',
                    templet: function (d) {
                        if (d.checkState == 0) {
                            return '<span style="color: #e80f0f">' + '未审核' + '</span>';
                        } else if (d.checkState == 1) {
                            return '<span style="color: #e80f0f">' + '审核通过' + '</span>';
                        } else {
                            return '<span style="color: #e80f0f">' + '审核不通过' + '</span>';
                        }
                    }
                },
                {field: 'createTime', align: 'center', title: '创建时间', width: '200'}
            ]]
        });
        /**
         * 表头工具栏
         */
        table.on('toolbar(auditFilter)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id)
                , data = checkStatus.data; //获取选中的数据
            switch (obj.event) {
                case 'del':
                    doDel(data);
                    break;
            }
            ;
        });

        /**
         * 删除
         */
        function doDel(data) {
            if (data.length === 0) {
                msg.error('请选择一条数据');
                return;
            } else {
                var ids = [];
                for (var i = 0; i < data.length; i++) {
                    ids += data[i].ownerHouseId + ',';
                }
                ids = ids.substr(0, ids.length - 1);
            }
            //弹出确认提示
            var len =data.length;
            layer.confirm('真的确定要删除选中的' + len + '条数据么，此操作会忽略正在审核的记录', function (index) {
                var loading = layer.load(0, {
                    shade: false,
                });

                // 提交 Ajax进行后端删除
                $.ajax({
                    type: "post",
                    url: ctx + "/publicUser/delRec",
                    data: {ids: ids},
                    success: function (res) {
                        layer.close(loading);
                        if (res.code == 200) {
                            msg.success("已成功删除"+len + '条数据!');
                            //刷新表格
                            table1.reload();
                        } else {
                            msg.error(res.message);
                        }
                    }
                });

                layer.close(index);
            });
        }


        table.on('tool(auditFilter)', function (obj) {
            const data = obj.data;
            if (obj.event === 'identityAuth') {
                //身份授权
                layer.open({
                    type: 1,
                    title: '身份审核',
                    area: ['390px', '260px'],
                    shade: 0,
                    offset: 'auto',
                    shadeClose: true,
                    content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' +
                        '请根据当前信息审核业主身份，审核通过后' +
                        '<span style=" background-color: #393D49; color: #ef1c0e; font-weight: 300;">' +
                        '不会下发相机权限，请单独通过相机授权按钮授权权限</span></div>',
                    btn: ['不通过', '通过'],
                    yes: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/identityAuth/" + data.ownerHouseId + '/' + 2,
                            success: function (data) {
                                if (data.code == 200) {
                                    msg.success("审核完成");
                                } else {
                                    msg.error(data.message)
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    }
                    ,
                    btn2: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/identityAuth/" + data.ownerHouseId + '/' + 1,
                            success: function (data) {
                                if (data.code == 200) {
                                    msg.success("审核完成");
                                } else {
                                    msg.error(data.message)
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    zIndex: layer.zIndex,
                    success: function (layero) {
                        layer.setTop(layero);
                    }
                });
            } else if (obj.event === 'cameraAuth') {
                //相机授权
                layer.open({
                    type: 1,
                    title: '相机授权',
                    area: ['390px', '260px'],
                    shade: 0,
                    offset: 'auto',
                    shadeClose: true,
                    content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' +
                        '设置当前用户的进出小区权限时间</div>',
                    btn: ['不允许', '1天', '1月', '半年', '1年', '10年'],
                    yes: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 0,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn2: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 1,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn3: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 2,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn4: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 3,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn5: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 4,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn6: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 5,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    zIndex: layer.zIndex,
                    success: function (layero) {
                        layer.setTop(layero);
                    }
                });
            } else if (obj.event === 'queryAuth') {
                layer.open({
                    type: 2,
                    title: "查看相机权限",
                    shadeClose: true,
                    shade: 0.1,
                    content: ctx + "/user/cameraPermissionPage" + "?openId=" + data.openId,
                    area: ['750px', '600px']
                })
            }
        });
    });
}

//切换到 审核通过 列表
function change2() {
    tab1 = 0;//待审核 列表
    tab2 = 1;//审核通过 列表
    tab3 = 0;//审核不通过 列表
    $("#friendNumberButton").show();

    //初始化 已审核 列表
    layui.use('table', function () {
        const table = layui.table;
        table2 = table.render({
            elem: '#passTable'
            , url: ctx + "/publicUser/queryPass",
            request: {
                pageName: 'currentPage',
                limitName: 'pageSize'
            },
            where: {
                condition: {
                    'name': $('#name').val(),
                    'phone': $('#phone').val()
                }
            },
            contentType: 'application/json',
            method: 'post',
            toolbar: '#toolbarDemo',
            page: true,
            limit: 10,
            limits: [10, 15, 20, 25, 30],
            title: '已审核列表',
            cols: [[
                // {type: 'checkbox'},
                {
                    title: '序号', width: 50, templet: function (obj) {
                        return obj.LAY_INDEX
                    }
                },
                {title: '操作', toolbar: '#barDemo2', width: '200', align: 'center'},
                {field: 'openId', align: 'center', title: '微信openId', width: '270'},
                {field: 'name', align: 'center', title: '姓名', width: '100'},
                {
                    field: 'imgUrl',
                    align: 'center',
                    title: '照片',
                    width: '170',
                    templet: '<div><img src="{{d.imgUrl}}"></div>'
                },
                {field: 'phone', align: 'center', title: '手机号', width: '120'},
                {field: 'friendNumber', align: 'center', title: '好友数量', width: '90'},
                {field: 'idCard', align: 'center', title: '身份证号', width: '180'},
                {
                    field: 'sex', align: 'center', title: '性别', width: '80',
                    templet: function (d) {
                        if (d.sex == 1) {
                            return '男';
                        } else if (d.sex == 2) {
                            return '女';
                        } else {
                            return '未知';
                        }
                    }
                },
                {field: 'age', align: 'center', title: '年龄', width: '80'},
                {field: 'communityName', align: 'center', title: '小区', width: '180'},
                {field: 'ldh', align: 'center', title: '楼栋号', width: '80'},
                {field: 'mph', align: 'center', title: '门牌号', width: '80'},
                {
                    field: 'checkState', align: 'center', title: '审核状态', width: '110',
                    templet: function (d) {
                        if (d.checkState == 0) {
                            return '<span style="color: #dec465">' + '未审核' + '</span>';
                        } else if (d.checkState == 1) {
                            return '<span style="color: #30e80f">' + '审核通过' + '</span>';
                        } else {
                            return '<span style="color: #e80f0f">' + '审核不通过' + '</span>';
                        }
                    }
                },
                {field: 'createTime', align: 'center', title: '创建时间', width: '200'}
            ]],
            height: '550'
        });

        table.on('tool(passFilter)', function (obj) {
            const data = obj.data;
            if (obj.event === 'identityAuth') {
                //身份授权
                layer.open({
                    type: 1,
                    title: '身份审核',
                    area: ['390px', '260px'],
                    shade: 0,
                    offset: 'auto',
                    shadeClose: true,
                    content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' +
                        '请根据当前信息审核业主身份，审核通过后' +
                        '<span style=" background-color: #393D49; color: #ef1c0e; font-weight: 300;">' +
                        '不会下发相机权限，请单独通过相机授权按钮授权权限</span></div>',
                    btn: ['不通过', '通过'],
                    yes: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/identityAuth/" + data.ownerHouseId + '/' + 2,
                            success: function (data) {
                                if (data.code == 200) {
                                    msg.success("审核完成");
                                } else {
                                    msg.error(data.message)
                                }
                            }
                        });
                        layer.closeAll();
                        table2.reload();
                    }
                    ,
                    btn2: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/identityAuth/" + data.ownerHouseId + '/' + 1,
                            success: function (data) {
                                if (data.code == 200) {
                                    msg.success("审核完成");
                                } else {
                                    msg.error(data.message)
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    zIndex: layer.zIndex,
                    success: function (layero) {
                        layer.setTop(layero);
                    }
                });
            } else if (obj.event === 'cameraAuth') {
                //相机授权
                layer.open({
                    type: 1,
                    title: '相机授权',
                    area: ['390px', '260px'],
                    shade: 0,
                    offset: 'auto',
                    shadeClose: true,
                    content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' +
                        '设置当前用户的进出小区权限时间</div>',
                    btn: ['不允许', '1天', '1月', '半年', '1年', '10年'],
                    yes: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 0,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn2: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 1,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn3: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 2,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn4: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 3,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn5: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 4,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn6: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 5,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table2.reload();
                    },
                    zIndex: layer.zIndex,
                    success: function (layero) {
                        layer.setTop(layero);
                    }
                });
            } else if (obj.event === 'queryAuth') {
                layer.open({
                    type: 2,
                    title: "查看相机权限",
                    shadeClose: true,
                    shade: 0.1,
                    content: ctx + "/user/cameraPermissionPage" + "?openId=" + data.openId,
                    area: ['750px', '600px']
                })
            } else if (obj.event === 'friendNumber') {
                layer.open({
                    type: 2,
                    title: "好友上限",
                    shadeClose: true,
                    shade: 0.1,
                    content: ctx + "/user/friendNumberPage" + "?openId=" + data.openId,
                    area: ['400px', '250px']
                })
            }
        });
    });
}


//切换到 不通过 列表
function change3() {
    tab1 = 0;//待审核 列表
    tab2 = 0;//已审核 列表
    tab3 = 1;//审核不通过 列表

    //初始化 已审核 列表
    layui.use('table', function () {
        const table = layui.table;
        table3 = table.render({
            elem: '#noPassTable'
            , url: ctx + "/publicUser/queryNoPass",
            request: {
                pageName: 'currentPage',
                limitName: 'pageSize'
            },
            where: {
                condition: {
                    'name': $('#name').val(),
                    'phone': $('#phone').val()
                }
            },
            contentType: 'application/json',
            method: 'post',
            // toolbar: '#toolbarDemo',
            toolbar: '#func-export-toolbar3',
            page: true,
            limit: 10,
            limits: [10, 15, 20, 25, 30],
            title: '已审核列表',
            cols: [[
                {type: 'checkbox'},
                {
                    title: '序号', width: 50, templet: function (obj) {
                        return obj.LAY_INDEX
                    }
                },
                {title: '操作', toolbar: '#barDemo3', width: '200', align: 'center'},
                {field: 'openId', align: 'center', title: '微信openId', width: '270'},
                {field: 'name', align: 'center', title: '姓名', width: '100'},
                {
                    field: 'imgUrl',
                    align: 'center',
                    title: '照片',
                    width: '170',
                    templet: '<div><img src="{{d.imgUrl}}"></div>'
                },
                {field: 'phone', align: 'center', title: '手机号', width: '120'},
                {field: 'idCard', align: 'center', title: '身份证号', width: '180'},
                {
                    field: 'sex', align: 'center', title: '性别', width: '80',
                    templet: function (d) {
                        if (d.sex == 1) {
                            return '男';
                        } else if (d.sex == 2) {
                            return '女';
                        } else {
                            return '未知';
                        }
                    }
                },
                {field: 'age', align: 'center', title: '年龄', width: '80'},
                {field: 'communityName', align: 'center', title: '小区', width: '180'},
                {field: 'ldh', align: 'center', title: '楼栋号', width: '80'},
                {field: 'mph', align: 'center', title: '门牌号', width: '80'},
                {
                    field: 'checkState', align: 'center', title: '审核状态', width: '110',
                    templet: function (d) {
                        if (d.checkState == 0) {
                            return '<span style="color: #e80f0f">' + '未审核' + '</span>';
                        } else if (d.checkState == 1) {
                            return '<span style="color: #e80f0f">' + '审核通过' + '</span>';
                        } else {
                            return '<span style="color: #e80f0f">' + '审核不通过' + '</span>';
                        }
                    }
                },
                {field: 'createTime', align: 'center', title: '创建时间', width: '200'}
            ]],
            height: '550'
        });
        /**
         * 表头工具栏
         */
        table.on('toolbar(noPassFilter)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id)
                , data = checkStatus.data; //获取选中的数据
            switch (obj.event) {
                case 'del3':
                    doDel3(data);
                    break;
            }
            ;
        });

        /**
         * 删除
         */
        function doDel3(data) {
            if (data.length === 0) {
                msg.error('请选择一条数据');
                return;
            } else {
                var ids = [];
                for (var i = 0; i < data.length; i++) {
                    ids += data[i].ownerHouseId + ',';
                }
                ids = ids.substr(0, ids.length - 1);
            }
            //弹出确认提示
            var len =data.length;
            layer.confirm('真的确定要删除选中的' + len + '条数据么，此操作会忽略正在审核的记录', function (index) {
                var loading = layer.load(0, {
                    shade: false,
                });

                // 提交 Ajax进行后端删除
                $.ajax({
                    type: "post",
                    url: ctx + "/publicUser/delRec",
                    data: {ids: ids},
                    success: function (res) {
                        layer.close(loading);
                        if (res.code == 200) {
                            msg.success("已成功删除"+len + '条数据!');
                            //刷新表格
                            table3.reload();
                        } else {
                            msg.error(res.message);
                        }
                    }
                });

                layer.close(index);
            });
        }


        table.on('tool(noPassFilter)', function (obj) {
            const data = obj.data;
            if (obj.event === 'identityAuth') {
                //身份授权
                layer.open({
                    type: 1,
                    title: '身份审核',
                    area: ['390px', '260px'],
                    shade: 0,
                    offset: 'auto',
                    shadeClose: true,
                    content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' +
                        '请根据当前信息审核业主身份，审核通过后' +
                        '<span style=" background-color: #393D49; color: #ef1c0e; font-weight: 300;">' +
                        '不会下发相机权限，请单独通过相机授权按钮授权权限</span></div>',
                    btn: ['不通过', '通过'],
                    yes: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/identityAuth/" + data.ownerHouseId + '/' + 2,
                            success: function (data) {
                                if (data.code == 200) {
                                    msg.success("审核完成");
                                } else {
                                    msg.error(data.message)
                                }
                            }
                        });
                        layer.closeAll();
                        table3.reload();
                    }
                    ,
                    btn2: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/identityAuth/" + data.ownerHouseId + '/' + 1,
                            success: function (data) {
                                if (data.code == 200) {
                                    msg.success("审核完成");
                                } else {
                                    msg.error(data.message)
                                }
                            }
                        });
                        layer.closeAll();
                        table3.reload();
                    },
                    zIndex: layer.zIndex,
                    success: function (layero) {
                        layer.setTop(layero);
                    }
                });
            } else if (obj.event === 'cameraAuth') {
                //相机授权
                layer.open({
                    type: 1,
                    title: '相机授权',
                    area: ['390px', '260px'],
                    shade: 0,
                    offset: 'auto',
                    shadeClose: true,
                    content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' +
                        '设置当前用户的进出小区权限时间</div>',
                    btn: ['不允许', '1天', '1月', '半年', '1年', '10年'],
                    yes: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 0,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn2: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 1,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn3: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 2,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn4: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 3,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn5: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 4,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    btn6: function () {
                        $.ajax({
                            type: 'get',
                            url: ctx + "/user/cameraAuth/" + data.id + '/' + data.communityId + '/' + 0 + '/' + 5,
                            success: function (data) {
                                if (data) {
                                    msg.success("修改成功");
                                }
                            }
                        });
                        layer.closeAll();
                        table1.reload();
                    },
                    zIndex: layer.zIndex,
                    success: function (layero) {
                        layer.setTop(layero);
                    }
                });
            } else if (obj.event === 'queryAuth') {
                layer.open({
                    type: 2,
                    title: "查看相机权限",
                    shadeClose: true,
                    shade: 0.1,
                    content: ctx + "/user/cameraPermissionPage" + "?openId=" + data.openId,
                    area: ['750px', '600px']
                })
            }
        });

    });
}

//查询
function query() {
    if (tab1 === 1) {
        table1.reload({
            where: {
                condition: {
                    'name': $('#name').val(),
                    'phone': $('#phone').val()
                }
            }
        });
    } else if (tab2 === 1) {
        table2.reload({
            where: {
                condition: {
                    'name': $('#name').val(),
                    'phone': $('#phone').val()
                }
            }
        });
    } else if (tab3 === 1) {
        table3.reload({
            where: {
                condition: {
                    'name': $('#name').val(),
                    'phone': $('#phone').val()
                }
            }
        });
    }
}
